#ifndef SUDOKUCELL_H
#define SUDOKUCELL_H

#include <QLineEdit>
#include <QRegularExpressionValidator>

class SudokuCell : public QLineEdit
{
    Q_OBJECT
    Q_PROPERTY(bool fixed READ isFixed WRITE setFixed NOTIFY fixedChanged)
    Q_PROPERTY(bool correct READ isCorrect WRITE setCorrect NOTIFY correctChanged)

public:
    explicit SudokuCell(int row, int col, QWidget *parent = nullptr);
    
    void setInitialValue(int value, bool isFixed);
    void setFixed(bool fixed);
    void setCorrect(bool correct);
    bool isFixed() const { return m_isFixed; }
    bool isCorrect() const { return m_isCorrect; }
    void reset();

signals:
    void valueChanged(int row, int col, int value);
    void fixedChanged(bool fixed);
    void correctChanged(bool correct);

protected:
    void focusInEvent(QFocusEvent *event) override;
    void focusOutEvent(QFocusEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;

private slots:
    void onTextChanged(const QString &text);

private:
    int m_row;
    int m_col;
    bool m_isFixed;
    bool m_isCorrect;
    int m_initialValue;
};

#endif